package com.t18;

import java.io.*;

/**
 * Created by xuyiwei on 2018/9/2.
 */
public class StoringAndRecoveringData {
    public static void main(String[] args) throws IOException {
        DataOutputStream out = new DataOutputStream(
                new BufferedOutputStream(
                        new FileOutputStream("/Users/xuyiwei/Documents/javaBase/jdk/src/com/t18/StoringAndRecoveringData.txt")
                ));
        out.writeDouble(1.2d);
        out.writeUTF("That was 在pi");
        out.writeDouble(1.43d);
        out.writeUTF("Square root of 2");
        out.close();
        DataInputStream in = new DataInputStream(
                new BufferedInputStream(
                        new FileInputStream("/Users/xuyiwei/Documents/javaBase/jdk/src/com/t18/StoringAndRecoveringData.txt")
                )
        );
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
        /**
         * 1.2
         That was pi
         1.43
         Square root of 2
         */
    }
}
